import React, { Component } from 'react'
import qs from 'querystring'

const data = [
  {id: '001', content: "你好，R"},
  {id: '002', content: "你好，E"},
  {id: '003', content: "你好，A"}
]

export default class Detail extends Component {
  render() {
    // 接收params参数
    // const {id, title} = this.props.match.params
    
    // 接收search参数
    const {search} = this.props.location
    const {id, title} = qs.parse(search.slice(1))
    const findResult = data.find(detailObj => detailObj.id === id)

    return (
      <ul>
        <li>Id: {id}</li>
        <li>Title: {title}</li>
        <li>Content: {findResult.content}</li>
      </ul>
    )
  }
}
